package com.ruoyi.parameter.service.impl;

import com.ruoyi.data.DataUtils;
import com.ruoyi.parameter.domain.HouseDoorParameterT;
import com.ruoyi.parameter.mapper.HouseDoorParameterTMapper;
import com.ruoyi.parameter.service.IHouseDoorParameterTService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 户参数修改Service业务层处理
 *
 * @author tyq
 * @date 2023-04-25
 */
@Service
public class HouseDoorParameterTServiceImpl implements IHouseDoorParameterTService
{
    @Autowired
    private HouseDoorParameterTMapper houseDoorParameterTMapper;

    /**
     * 查询户参数修改
     *
     * @param doorId 户参数修改主键
     * @return 户参数修改
     */
    @Override
    public HouseDoorParameterT selectHouseDoorParameterTByDoorId(Long doorId)
    {
        return houseDoorParameterTMapper.selectHouseDoorParameterTByDoorId(doorId);
    }

    /**
     * 查询户参数修改列表
     *
     * @param houseDoorParameterT 户参数修改
     * @return 户参数修改
     */
    @Override
    public List<HouseDoorParameterT> selectHouseDoorParameterTList(HouseDoorParameterT houseDoorParameterT)
    {
        return houseDoorParameterTMapper.selectHouseDoorParameterTList(houseDoorParameterT);
    }

    /**
     * 修改户参数修改
     *
     * @param houseDoorParameterT 户参数修改
     * @return 结果
     */
    @Override
    @Transactional
    public int updateHouseDoorParameterT(HouseDoorParameterT houseDoorParameterT)
    {
        HouseDoorParameterT doorParameterVO = new HouseDoorParameterT();
        HouseDoorParameterT doorParameterT = new HouseDoorParameterT();
        doorParameterVO = houseDoorParameterTMapper.selectHouseDoorParameterTByDoorId(houseDoorParameterT.getDoorId());
        int doorParameterId = houseDoorParameterTMapper.getDoorParameterId();
        doorParameterT.setSpacePre(doorParameterVO.getSpace());
        doorParameterT.setPurposeIdPre(doorParameterVO.getPurposeId());
        doorParameterT.setCreater(houseDoorParameterT.getCreater());
        doorParameterT.setRemark(houseDoorParameterT.getRemark());
        doorParameterT.setHouseId(houseDoorParameterT.getHouseId());
        doorParameterT.setSpace(houseDoorParameterT.getSpace());
        doorParameterT.setPurposeId(houseDoorParameterT.getPurposeId());
        doorParameterT.setPrice(houseDoorParameterT.getPrice());
        doorParameterT.setPricePre(doorParameterVO.getPrice());
        houseDoorParameterTMapper.insertHouseDoorParameterT(doorParameterT);
        doorParameterVO.setSpace(doorParameterT.getSpace());
        doorParameterVO.setPurposeId(doorParameterT.getPurposeId());
        doorParameterVO.setPrice(doorParameterT.getPrice());
        doorParameterVO.setBudgetMoney(houseDoorParameterT.getBudgetMoney());
        return houseDoorParameterTMapper.updateHouseDoorParameterT(doorParameterVO);
    }
}
